Repository navigation
A mesh that does not deform is held compacted - #305
Merged
Merged
Conversation
A BLAS is built into the worst case its geometry could need, and a build that is done can say what it does need. The scene's upload built every BLAS and kept it as built. A mesh that does not deform is built once: its BLAS, traced fast as before, is copied when its batch's build is done into a structure of the size the build reported, and the one it was built in is freed. The builds go in batches as before and a batch is compacted before the next is built, so what is held at once is the compacted ones and one batch as built. Deforming meshes (posed skinned models', particle systems') are rebuilt every pose and stay as built, as do the meshes edits make and the procedural boxes'. - The TLAS was built with the last batch. A compacted copy is a write of the queue's own and goes out with whatever is submitted next: where several views share a device it went out with another's submit, the TLAS was built over a structure whose copy was not done, and on Metal that loses the instance (five unit tests failed in a run of the suite, none alone). The copies are submitted and waited for, then the TLAS is built by itself. - wgpu builds no compacted structure again. A mesh of the build whose geometry an edit rewrites where it lies takes a new BLAS of the same geometries first, built fast as an edit's (`Gpu::renew_mesh`). - `THREERT_BLAS_COMPACT=0` leaves every BLAS as built. Measured on an Apple M4 (Metal; the roadmap entry has the figures): Tokyo's 1,248 structures 2,401 MB -> 1,129, Bistro's 293 -> 137, Zero-Day's 608 -> 489, a scene of skinned models alone nothing. Bistro's offline render is the same in every pixel; twelve clips beside main's build have its pictures and its frame time (within 0.5 %), and load in the time they took. `tri_blas_mb` is still what the builds allocate: wgpu does not hand out a structure's size. Not done: the meshes that come by edits (a streamed city's cells) stay as built. Not checked on Vulkan. Unit suite 297 (one new), render suite 276. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
wryyx
added a commit
to wryyx/ThreeRT
that referenced
this pull request
Dec 2, 2026
A cutout's maps (renderer/src/cutout.rs) are made of its triangles' texture coordinates when the scene is prepared, and an instance an edit places takes those of the scene's instances of its mesh. It took them too when the edit had rewritten that mesh where it lies (a `dynamicGeometry` mesh, the same sections): an emitter's shadow rays then asked the map of the triangles the mesh had had. A card's texture coordinates mirrored at run time kept its old picture of light and shadow on the ground. The edit state keeps the meshes whose triangles an edit wrote (a new mesh, a freed one's slot, one rewritten where it lies), and an instance of one takes no map: its cutout is opaque to those rays, as a cutout whose material or texture was edited already is, until the scene is prepared again. To make the map again at the edit needs the texture's pixels and room in the maps' stream then: not done. `shadow/cutout-emitter-geometry-edit-live`: the card of `shadow/cutout-emitter-side` with its u mirrored after three frames. The point the old map lit, against a point a lamp under the card lights: 0.25 before (under both traversals), 0.003 now; with the alpha tested 0.085. Unit suite 297, render suite 277 (on main with meshy-dev#305). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
wryyx
added a commit
that referenced
this pull request
Dec 2, 2026
A cutout's maps (renderer/src/cutout.rs) are made of its triangles' texture coordinates when the scene is prepared, and an instance an edit places takes those of the scene's instances of its mesh. It took them too when the edit had rewritten that mesh where it lies (a `dynamicGeometry` mesh, the same sections): an emitter's shadow rays then asked the map of the triangles the mesh had had. A card's texture coordinates mirrored at run time kept its old picture of light and shadow on the ground. The edit state keeps the meshes whose triangles an edit wrote (a new mesh, a freed one's slot, one rewritten where it lies), and an instance of one takes no map: its cutout is opaque to those rays, as a cutout whose material or texture was edited already is, until the scene is prepared again. To make the map again at the edit needs the texture's pixels and room in the maps' stream then: not done. `shadow/cutout-emitter-geometry-edit-live`: the card of `shadow/cutout-emitter-side` with its u mirrored after three frames. The point the old map lit, against a point a lamp under the card lights: 0.25 before (under both traversals), 0.003 now; with the alpha tested 0.085. Unit suite 297, render suite 277 (on main with #305). Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A BLAS is built into the worst case its geometry could need, and a build that is done can say what it does need. The scene's upload built every BLAS and kept it as built: Bistro's 2.8 million triangles held 293 MB of them, Tokyo's 23 million 2.4 GB.
What changes
Gpu::upload. A mesh that does not deform is built once. Its BLAS (traced fast, as before) is copied when its batch's build is done into a structure of the size the build reported, and the one it was built in is freed. The batches are as they were, and a batch is compacted before the next is built: what is held at once is the compacted ones and one batch as built. Deforming meshes (posed skinned models', particle systems') are rebuilt every pose and stay as built; so do the meshes edits make and the procedural boxes'.Gpu::renew_mesh).THREERT_BLAS_COMPACT=0leaves every BLAS as built.Measured (Apple M4, Metal)
Limits
tri_blas_mbis what the builds allocate, as it was: wgpu does not hand out a structure's size. (The sizes above are wgpu-core's own, printed for this measurement.) A function for it in the vendored wgpu was written and taken out again: the browser's module is built against the released wgpu, and the renderer's source is kept to what that one has.Checks
Unit suite 297 (one new: a compacted mesh's geometry changed where it lies, twice, each against a build; without the new BLAS it fails with wgpu's error), render suite 276,
npm run typecheck,npm test, and the two wasm32 builds (rendereras a library,renderer/web).🤖 Generated with Claude Code